#include"main.h"
void Enter_Flight()
{
    int i =0;int num;char p[20]="0";
    for ( i = 0; i < len; i++)
    {
        if(FIT[i].id==0)
        {
            break;
        }
    }
    printf("please enter number\n");
    scanf("%s",p);
    strcpy(FIT[i].number,p);

    printf("please enter id\n");
    scanf("%d",&num);
    FIT[i].id = num;

    printf("please enter Departurn\n");
    scanf("%s",p);
    strcpy(FIT[i].Departure,p);

    printf("please enter Destination\n");
    scanf("%s",p);
    strcpy(FIT[i].Destination,p);

    printf("please enter Departure_Time\n");
    scanf("%s",p);
    strcpy(FIT[i].Departure_Time,p);

    printf("please enter price\n");
    scanf("%d",&num);
    FIT[i].Price = num;

    printf("please enter MAX passenger\n");
    scanf("%d",&num);
    FIT[i].Max_passenger = num;
    printf("enter sucessful!\n");
    count++;
    getchar();
    printf("any other contine");
    getchar();
   
}

int Find_fight(char* num)
{
    int i=0;
    for ( i = 0; i <len; i++)
    {
        if(!strcmp(FIT[i].number,num))
        {
            printf("number:%s\n",FIT[i].number);
            printf("id:%d\n",FIT[i].id);
            printf("Departure:%s\n",FIT[i].Departure);
            printf("Destination:%s\n",FIT[i].Destination);
            printf("Destination_Time:%s\n",FIT[i].Departure_Time);
            printf("Price:%d\n",FIT[i].Price);
            printf("Max_passenger:%d\n",FIT[i].Max_passenger);
            clear();
    printf("any other contine");
    getchar();
            return i;
        }
        
    }
    printf("NO this fight\n");
    return -1;
}
void Delet_fight()
{
    int i =0;int j=0;
    char p[10];
    printf("please enter number to delet fight\n");
    scanf("%s",p);
    for ( i = 0; i < len; i++)
    {
       if(strcmp(FIT[i].number,p))
       {
        if(i==len-1){printf("None\n");}
        continue;
       }
       else
       {
        printf("Have find flight\n");
          for ( j =i; j < len-1; j++)
          {
             
             FIT[j]=FIT[j+1];
             if(FIT[j].id == 0)
             {
                printf("sucssful!\n");
                count--;
               break;
             }
            
          }
          
       }
    }
    
    
}

int Book_ifm(char* num)
{
    int i =0;
    int x=ONLY_indext(num);
    printf("passengers have %d\n",FIT[x].has_buy);
    for ( i = 0; i < len2; i++)
    {
       if(strcmp(num,pas[i].flight_num) == 0)
       {
           printf("%s\n",pas[i].name);
       }
    }
    
}

void fund_wait(int num)
{
    int i=0;
    int x =FIT[num].wait;
    printf("wait book passengers number is :%d\n",x);
   while(strlen(FIT[num].list_wait[i]) !=0)
    {
    printf("wait passenger name:\n");
    puts(FIT[num].list_wait[i]);
    i++;
    }
    
}
void ALL_fight()
{
    int i=0;
    for ( i = 0; i <len; i++)
    {
        if(FIT[i].id==0)
        {
            return;
        }
        
            printf("number:%s  ",FIT[i].number);
            printf("id:%d  ",FIT[i].id);
            printf("Departure:%s  ",FIT[i].Departure);
            printf("Destination:%s  ",FIT[i].Destination);
            printf("Destination_Time:%s  ",FIT[i].Departure_Time);
            printf("Price:%d ",FIT[i].Price);
            printf("Max_passenger:%d\n",FIT[i].Max_passenger);               
    }
}
int ONLY_indext(char* num)
{
    int i=0;
    for ( i = 0; i <len; i++)
    {
        if(!strcmp(FIT[i].number,num))
        {         
            return i;
        }
    }
    return -1;
}